#!/bin/sh
RUNOPTIONS="$@ $OPTIONS"

if [[ -f /etc/bind/rndc.key ]]; then
    echo "rndc.key allready existed!"
else
    cp /rndc.key /etc/bind/rndc.key
fi
if [[ -f /etc/bind/bind.keys ]]; then
    echo "bind.keys allready existed!"
else
    cp /bind.keys /etc/bind/bind.keys
fi

chown -R root:named /etc/bind /var/run/named
chown -R named:named /var/cache/bind
chmod -R 770 /var/cache/bind /var/run/named
chmod -R 750 /etc/bind

# Run in foreground and log to STDERR (console):
exec /usr/sbin/named -c /etc/bind/named.conf -g -u named $RUNOPTIONS
